package com.applet.mallappletbackstage.controller;


import com.applet.mallappletbackstage.entity.PersonnelInfo;
import com.applet.mallappletbackstage.entity.ProjectExperience;
import com.applet.mallappletbackstage.entity.vo.UInfoVO;
import com.applet.mallappletbackstage.service.ProjectExperienceService;
import com.applet.mallappletbackstage.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author X
 * @since 2020-08-17
 */
@RestController
@RequestMapping("/mallappletbackstage/project-experience")
public class ProjectExperienceController {

    @Autowired
    private ProjectExperienceService projectExperienceService;

    /***
     * 添加项目经验
     * @param openid
     * @param projectExperience
     * @return
     */
    @PostMapping("/addProject/{openid}")
    public R addProject(@PathVariable(value = "openid")String openid,
                   @RequestBody ProjectExperience projectExperience){
        int count = projectExperienceService.addProject(openid,projectExperience);
        if(count>0){
            return R.success("成功完善个人信息");
        }
        return R.fail("完善个人信息失败");
    }

    /***
     * 查询数据库项目经验集合
     * @param openid
     * @return
     */
    @GetMapping("/getProject/{openid}")
    public R getProject(@PathVariable(value = "openid")String openid) {
        List<ProjectExperience> projectExperiences = projectExperienceService.getProject(openid);
        return R.success(projectExperiences);
    }

    /***
     * 删除项目经验
     * @param id
     * @return
     */
    @DeleteMapping("/deleteProject/{id}")
    public R deleteProject(@PathVariable(value = "id")String id) {
        int count = projectExperienceService.deleteProject(id);
        if(count>0){
            return R.success("成功删除");
        }
        return R.fail("删除失败");
    }

}

